package top.tangyh.lamp.care.mapper;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import top.tangyh.basic.base.mapper.SuperMapper;
import top.tangyh.lamp.care.entity.BHl7YzYaoExe;
import org.springframework.stereotype.Repository;
import top.tangyh.lamp.care.vo.query.YzYaoExeQueryVO;

import java.util.List;

import static top.tangyh.lamp.common.constant.CommonConstant.NO_NUMBER;

/**
 * <p>
 * Mapper 接口
 * 医嘱实际执行表
 * </p>
 *
 * @author zqb
 * @date 2024-07-22 15:09:14
 * @create [2024-07-22 15:09:14] [zqb] [代码生成器生成]
 */
@Repository
public interface BHl7YzYaoExeMapper extends SuperMapper<BHl7YzYaoExe> {

    default List<BHl7YzYaoExe> selectListByTimeHospitalNumbers(List<String> hospitalNumbers) {
        LambdaQueryWrapper<BHl7YzYaoExe> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper
                .in(BHl7YzYaoExe::getHospitalNumber, hospitalNumbers)
                .eq(BHl7YzYaoExe::getIsDeleted,NO_NUMBER);
        return this.selectList(queryWrapper);
    }

    default List<BHl7YzYaoExe> selectListByTimeHospitalNumber(String hospitalNumbers) {
        LambdaQueryWrapper<BHl7YzYaoExe> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper
                .eq(BHl7YzYaoExe::getHospitalNumber, hospitalNumbers)
                .eq(BHl7YzYaoExe::getIsDeleted,NO_NUMBER);
        return this.selectList(queryWrapper);
    }

    default List<BHl7YzYaoExe> selectListByQuery(YzYaoExeQueryVO queryVO) {
        String patientIdent = queryVO.getPatientIdent();
        String hospitalNumber = queryVO.getHospitalNumber();
        Long startTime = queryVO.getStartTime();
        Long endTime = queryVO.getEndTime();
        LambdaQueryWrapper<BHl7YzYaoExe> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(StrUtil.isNotBlank(patientIdent), BHl7YzYaoExe::getPatientIdent, patientIdent)
                .eq(StrUtil.isNotBlank(hospitalNumber), BHl7YzYaoExe::getHospitalNumber, hospitalNumber)
                .gt(startTime != null, BHl7YzYaoExe::getStartTime, startTime)
                .lt(endTime != null, BHl7YzYaoExe::getStartTime, endTime);
        return this.selectList(queryWrapper);
    }


}


